#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: update_01_20210508.py
# @time: 2021/5/8 10:08
# @desc:
from application.history_clamp.crud import get_history_clamp_in_all_scene, is_scene_binded_history_clamp
from views.configs import HISTORY_CLAMP_COLLECTION
from utils.mongo_tools import retrieve_all_mongo_values, update_mongo_value

history_clamps = retrieve_all_mongo_values(
    {},
    collection_name=HISTORY_CLAMP_COLLECTION,
)

scene_history_clamp_list = get_history_clamp_in_all_scene()

for i in history_clamps:
    if type(i["tag"]["rpsNumber"]) is int:
        print(i)
    # if i["number"] in scene_history_clamp_list:
    #     i["isSceneBinded"] = True
    # else:
    #     i["isSceneBinded"] = False
    #
    # print(i["number"], i["isSceneBinded"])
    #
    # try:
    #     if None is i["tag"]["airNumber"]:
    #         i["tag"]["airNumber"] = 0
    # except:
    #     i["tag"]["airNumber"] = 0
    #
    # try:
    #     if None is i["tag"]["rpsNumber"]:
    #         i["tag"]["rpsNumber"] = 0
    # except:
    #     i["tag"]["rpsNumber"] = 0
    #
    # try:
    #     if None is i["tag"]["rpsType"]:
    #         i["tag"]["rpsType"] = []
    # except:
    #     i["tag"]["rpsType"] = []
    #
    # update_mongo_value(
    #     filter_condition={"number": i["number"]},
    #     new_value={"$set": i},
    #     collection_name=HISTORY_CLAMP_COLLECTION,
    # )
